home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / lcad40.zip / LC.LSP < prev    next >
Lisp/Scheme  |  1992-05-11  |  6KB  |  178 lines

  1.  
  2. ; LaunchCAD Autolisp program version 4.01
  3.  
  4. ; Note: add the line:     (load"lc")     to the end of your ACAD.LSP file.
  5. ; If you do not have an ACAD.LSP file then you can rename this file to ACAD.LSP
  6. ; or add the contents of this file to your present ACAD.LSP file.
  7.  
  8. (princ "\nLoading LaunchCAD...")
  9. (if(< (substr(getvar "ACADVER")1 2) "11")
  10.   (setvar "MENUECHO" 1))                        ; this makes INSERT work right
  11.  
  12. (defun lc_shell (mode dt / ce me dir f)         ; call LaunchCAD in shell mode
  13.   (setq ce (getvar "CMDECHO")
  14.     me (getvar "MENUECHO"))
  15.   (setvar "CMDECHO" 0)                          ; don't echo commands
  16.   (setvar "MENUECHO" 1)                         ; do echo menu commands
  17.   (command ".SCRIPT" "BLANK")
  18. ; (command "sh" "mode co80")                    ; decomment for dual screen
  19.   (if (= dt "d") (progn
  20.     (setq dir (getvar "DWGPREFIX"))
  21.     (command "launchcad" (strcat mode " " dir)) ; invoke LaunchCAD
  22.   ) ;else
  23.     (command "launchcad" mode)
  24.   )
  25. ; (command "sh" "mode mono")                    ; decomment for dual screen
  26. ; (graphscr)                    ;    "           "
  27.   (if(null(setq username (getenv "USERNAME")))
  28.     (setq username "LC"))
  29.   (command ".SCRIPT" username)                  ; run the script
  30.   (if (setq f (open(findfile (strcat username ".SCR")) "w"))
  31.     (setq f (close f)))                         ; just in case...
  32.   (setvar "CMDECHO" ce)                         ; restore CMDECHO
  33.   (setvar "MENUECHO" me)                        ; restore MENUECHO
  34.   (princ)
  35. )
  36.  
  37. ; Note: You may edit this lisp file to rename the following functions
  38. ; to any name that you wish so long as it does not conflict with an
  39. ; AutoCAD internal command.
  40.  
  41. ; Execute LaunchCAD from within AutoCAD (in shell mode)
  42.  
  43. (defun c:lc ()     (lc_shell "/s" "d"))       ; shell mode menu
  44. (defun c:lce ()  (lc_shell "/e" "d"))       ; end and select another
  45. (defun c:lcw ()  (lc_shell "/w" "d"))       ; wblock *;quit and select another
  46. (defun c:lcq ()  (lc_shell "/q" "d"))       ; quit and select another
  47. (defun c:ins ()  (lc_shell "/i" "s"))       ; Insert
  48. (defun c:*ins () (lc_shell "/*" "s"))       ; Exploding Insert
  49. (defun c:lisp () (lc_shell "/l" "s"))       ; Lisp
  50. (defun c:dxf ()  (lc_shell "/d" "s"))       ; DXFIN
  51. (defun c:dxb ()  (lc_shell "/b" "s"))       ; DXBIN
  52. (defun c:vs ()     (lc_shell "/v" "s"))       ; VSlide
  53. (defun c:mu ()     (lc_shell "/m" "s"))       ; Menu
  54. (defun c:sty ()  (lc_shell "/t" "s"))       ; Text Style
  55. (defun c:xr ()     (lc_shell "/x" "s"))       ; XREF attach
  56. (defun c:ads ()  (lc_shell "/a" "s"))       ; ADS (XLOAD"XX")
  57. (defun fi ()     (lc_shell "/f" "s"))       ; invoke LaunchCAD file Mode
  58.  
  59. (defun lc_var(var)
  60.   (cadr(assoc var (read(getenv "LAUNCHCAD"))))
  61. )
  62.  
  63. (defun ck_slide ( / sldfile)
  64.   (if(and(not checked) (= T (lc_var "MSLIDE"))) (progn
  65.     (setq checked T
  66.       sldfile (strcat (getvar "DWGNAME") ".sld"))
  67.     (if(not(findfile sldfile)) (progn
  68.         (princ "\nCreating Slide File...")
  69.         (command "MSLIDE" "")
  70.     (princ "done \n")
  71.     ))
  72.   ))
  73. )
  74.  
  75. (defun date(val / s y m d)
  76.   (setq s (rtos val 2 0)
  77.     y (substr s 3 2)
  78.     m (substr s 5 2)
  79.     d (substr s 7 2)
  80.   )
  81.   (strcat m "/" d "/" y)
  82. )
  83.  
  84. (defun time(val / str h m s)
  85.   (setq str (rtos val 2 6)
  86.     h (substr str 10 2)
  87.     m (substr str 12 2)
  88.     s (substr str 14 2)
  89.   )
  90.   (strcat h ":" m ":" s)
  91. )
  92.  
  93. (defun log ( which / fp logfile q c)
  94.   (if(= T (lc_var "LOG")) (progn
  95.     (setq logfile(strcat(getvar"DWGNAME")(lc_var"LOG_EXT"))
  96.       fp (open logfile "a")
  97.       q "\"" c ", "
  98.     )
  99.     (princ "\nUpdating Log File...")
  100.     (princ(strcat q which q
  101.           c q (getvar"DWGNAME") q
  102.           c q (if(/= username "LC") username "") q
  103.           c q (date(getvar"CDATE")) q
  104.           c q (time(getvar"CDATE")) q
  105.           c (rtos(* 24.0 (getvar"TDINDWG")) 2 3)
  106. ;           c (rtos(getvar"DATE") 2 9)           ; decomment for more
  107. ;           c (rtos(getvar"TDUPDATE") 2 9)       ; data in log file
  108.           "\n")
  109.     fp)
  110.   (close fp)
  111.   (princ "done ")
  112.   ))
  113. )
  114.  
  115. ; Redefine the QUIT command to run quit.scr in order to
  116. ; bypass the AutoCAD opening menu.
  117.  
  118. (defun c:quit ()
  119.   (setvar "CMDECHO" 0)
  120.   (initget "No Yes")
  121.   (if(= "Yes" (getkword
  122.     "\nDo you really want to discard\nall changes to drawing[y/N]: "))
  123.   (progn
  124.     (log "QUIT")
  125.     (command ".SCRIPT" "QUIT")
  126.   ))
  127.   (princ)
  128. )
  129.  
  130. ; Redefine the END command to run end.scr in order to
  131. ; bypass the AutoCAD opening menu.
  132.  
  133. (defun c:end ()
  134.   (setvar "CMDECHO" 0)
  135.   (ck_slide)
  136.   (log "END")
  137.   (command ".SCRIPT" "END")              ; run end.scr which bypasses menu
  138.   (princ)
  139. )
  140.  
  141. (defun c:save ()
  142.   (ck_slide)
  143.   (log "SAVE")
  144.   (command ".SAVE")
  145.   (princ)
  146. )
  147.  
  148. (defun c:wend ()
  149.   (setvar "CMDECHO" 0)
  150.   (log "WEND")
  151.   (command ".SCRIPT" "WEND")             ; run wend.scr which saves drawing
  152.   (princ)                 ; using wblock * and bypasses menu
  153. )
  154.  
  155. ; Undefine the AutoCAD drawing editor END and QUIT commands so that
  156. ; the end and quit functions defined above will work in place of the
  157. ; internal commands (.end and .quit will still work like normal)
  158. ; NOTE: (lc:su) MUST be in STARTUP.LSP or the S::STARTUP function
  159. ; in ACAD.LSP
  160.  
  161. (defun lc:su()
  162.   (command "UNDEFINE" "QUIT")
  163.   (command "UNDEFINE" "SAVE")
  164.   (command "UNDEFINE" "END")
  165.   (princ "\nEND, SAVE and QUIT commands redefined...")
  166.   (if(null(setq username (getenv "USERNAME")))
  167.     (setq username "LC"))
  168.   (if (setq f (open(findfile (strcat username ".SCR")) "w"))
  169.     (setq f (close f)))             ; delete script file
  170.   (log "OPEN")
  171.   (princ "\nLaunchCAD initialized.")
  172.   (princ)
  173. )
  174.  
  175. (princ "\nLaunchCAD version 4.0 ")
  176. (princ)
  177.  
  178.